"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RetCodeModel = void 0;
const RetCodeDefine_1 = require("../config/RetCodeDefine");
const ProtoUtils_1 = require("../engine/socketserver/protocol/ProtoUtils");
const ProtoConfig_1 = require("../engine/socketserver/protocol/ProtoConfig");
class RetCodeModel {
    constructor() {
        this.retCode = 0;
        this.message = null;
    }
    static deserializeToModel(protoPack) {
        let model = new RetCodeModel();
        model.retCode = protoPack.getRetcode();
        model.message = protoPack.getMessage();
        return model;
    }
    static createRetCodeModel(retCode = RetCodeDefine_1.RetCodeDefine.OK, message = null) {
        let model = new RetCodeModel();
        model.retCode = retCode;
        if (message == null) {
            message = RetCodeDefine_1.RetCodeDefine.code2Msg.get(retCode);
        }
        model.message = message;
        return model;
    }
    static serializeBinary(model) {
        let protoPack = ProtoUtils_1.ProtoUtils.Create(ProtoConfig_1.ProtoConfig.resp_error_code);
        protoPack.setRetcode(model.retCode);
        protoPack.setMessage(model.message);
        return protoPack;
    }
}
exports.RetCodeModel = RetCodeModel;
